package learningThread.api.yieldApi;

public class MyThread extends Thread{

    @Override
    public void run() {
        long begin = System.currentTimeMillis();
        int count = 0;
        for (int i = 0; i < 5000000; i++) {
//            Thread.yield();        // 放弃当前cpu资源，但是放弃的时间不确定,有可能刚放弃又马上得到时间片
            count = count + (i + 1);
        }
        long end = System.currentTimeMillis();
        System.out.println("用时:"+(end-begin));
    }
}
